<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>script跨域</title>
    <script>
        function sendScript() {
            var script = document.createElement("script");
            script.src = "./jsonp.php?callback=getData111";
            document.head.appendChild(script);// 必须加入页面，否则不会发送请求
            document.head.removeChild(script);// 删除标签
        }
        // 响应结束后的回调函数, 通过 参数获取需要的数据
        function getData111(name) {
            console.log('name:', name);
        }
    </script>
</head>
<body>
    <button onclick="sendScript()" >getData</button>
</body>
</html>